<%@ page import="com.situ.web.pojo.entity.Course" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 4/9/2024
  Time: 1:34 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="static/bootstrap-3.4.1-dist/css/bootstrap.css">
</head>
<body>
<%--${list}--%>
<%
    //JSP脚本，这里面可以任意写java代码
    //request、response:JSP内置对象
    List<Course> list = (List<Course>) request.getAttribute("list");
%>
<a class="btn btn-primary" href="/course?method=toAdd">添加</a>
<table class="table table-striped table-bordered table-hover table-condensed">
    <tr>
        <td>ID</td>
        <td>名字</td>
        <td>学分</td>
        <td>删除</td>
        <td>编辑</td>
    </tr>
    <%
        for (Course course : list) {
    %>
    <tr>
        <td><%=course.getId()%></td>
        <td><%=course.getName()%></td>
        <td><%=course.getCredit()%></td>
        <%--<td><a href="/deleteStudent?id=<%=course.getId()%>">删除</a></td>--%>
        <%--<td><a href="/course?method=deleteById&id=<%=course.getId()%>">删除</a></td>--%>
        <td><a href="javascript:void(0)" onclick="deleteById(<%=course.getId()%>)">删除</a></td>
        <td><a href="/course?method=toUpdate&id=<%=course.getId()%>">编辑</a></td>
    </tr>
    <%
        }
    %>
</table>
<script>
    function deleteById(id) {
        var isDelete = confirm('您确认要删除么?');
        if (isDelete) {
            location.href = '/course?method=deleteById&id=' + id;
        }
    }
</script>
</body>
</html>
